package com.hp.attendance.serlvet.leave;

import com.hp.attendance.service.LeaveService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
@WebServlet("/leaveReject")
public class LeaveRejectServlet extends HttpServlet {
    private LeaveService leaveService = new LeaveService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //驳回
        try {
            int id = Integer.parseInt(req.getParameter("id"));
            leaveService.updateLeave("已驳回",id);
            req.getRequestDispatcher("LeaveNotList").forward(req, resp);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
